libxl: strdup disk path before put it in qemu args array.
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 13 Dec 2010 17:59:02 +0000 (17:59 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Mon, 13 Dec 2010 17:59:02 +0000 (17:59 +0000)
In libxl_build_device_model_args_new, the path to the disk image are
freeed before there was actually use to make the arguments list of Qemu.
The patch strdups it.

This patch also changes argv[0] of the device model.
Now, it is the conventional argv[0], so is value come from
info->device_model.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 tools/libxl/libxl.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

tools/libxl/libxl.c

index 8fdfd45345a89555d79661b1c3e4f1f29ddf286f..16343b54264911dd8c5625bb56afe1b8a454daba 100644 (file)
@@ -1256,9 +1256,9 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,
     if (!dm_args)
         return NULL;
 
-    flexarray_set(dm_args, num++, "qemu-system-xen");
-    flexarray_set(dm_args, num++, "-xen-domid");
+    flexarray_set(dm_args, num++, libxl__strdup(gc, info->device_model));
 
+    flexarray_set(dm_args, num++, "-xen-domid");
     flexarray_set(dm_args, num++, libxl__sprintf(gc, "%d", info->domid));
 
     if (info->dom_name) {
@@ -1378,10 +1378,10 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,
     for (i; i < nb; i++) {
         if ( disks[i].is_cdrom ) {
             flexarray_set(dm_args, num++, "-cdrom");
-            flexarray_set(dm_args, num++, disks[i].physpath);
-        }else{
+            flexarray_set(dm_args, num++, libxl__strdup(gc, disks[i].physpath));
+        } else {
             flexarray_set(dm_args, num++, libxl__sprintf(gc, "-%s", disks[i].virtpath));
-            flexarray_set(dm_args, num++, disks[i].physpath);
+            flexarray_set(dm_args, num++, libxl__strdup(gc, disks[i].physpath));
         }
         libxl_device_disk_destroy(&disks[i]);
     }